<include file="__THEME__/header" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.form.js" ></script>
<link href="../Public/css/colleague.css" rel="stylesheet" type="text/css" />
<link href="../Public/css/space.css" rel="stylesheet" type="text/css" />
<div class="contents lbg B">
<include file="../Public/home_left" />
<script>
	
	function tChecked(o,target){

		if(o.checked){
			$.each($("input[rel='"+target+"']"),function(i,n){
				$(this).attr('checked',true);
			});
		}else{
			$.each($("input[rel='"+target+"']"),function(i,n){
				$(this).attr('checked','');
			});
		}
	}
</script>
  <div class="contents_min w787">
    <div class="write_info">
    <div class="mb10">
        	    <h3 class="tit_h3">{:L('my_contact')}</h3>
      </div>
      <div class="list_cate_nav">
      <div class="tab">
        <!-- 切换标签 begin  -->
        <ul>
          <li><span><a href="__URL__&act=index">{:L('nav_index')}</a></span></li>
          <li class="on"><span><a href="__URL__&act=add">{:L('nav_add')}</a></span></li>
          <li><span><a href="__URL__&act=search">{:L('nav_search')}</a></span></li>
          <li><span><a href="__URL__&act=track">{:L('nav_track')}</a></span></li>
          <li><span><a href="__URL__&act=followYou">{:L('nav_followyou')}</a></span></li>
          <li><span><a href="__URL__&act=followMe">{:L('nav_followme')}</a></span></li>		  
        </ul>
      </div>
      <div class="friendBox">
       <div class="FList mt10" style="width:800px">
                <h2 class="fB lh30 btmline">{:L('import_contact')}: </h2>
                <ul style="margin-top: 10px;" id="div_havaInit">
				<form action="__URL__&act=doadd" method="post" id="form_havaInit" autocomplete="off" />
				<input type="hidden" name="type" value="havaInit" />
                    <li class="ml10">
                    <div class="copylist L" style="width:450px;">
                    	<div class="tit_t">
                   	    	<div class="L alC" style="width:60px;">{:L('select_all')} <input name="" type="checkbox" value="" checked="true" onclick="tChecked(this,'haveInit[attention]')" /></div>
                        	<div class="L" style="width:140px;">{:L('follow_col')}</div>
                            <div class="L" style="width:110px;">{:L('col_group')}</div>				                     		
		                    <div class="L" style="width:80px;">{:L('status')}</div>
							<div class="L" style="width:30px;">{:L('remove')}</div>
                    		<div class="C"></div>
							
						</div>
						
                    <volist id="vo" name="findlist['haveInit']" key="k">
  
	                      <div class="tit_C" style="padding:0" id="c_list_{$vo.key}">
	                   	    <div class="L alC" style="width:60px;"><input style="margin-left:28px; margin-top:8px;*margin-top:5px;" name="haveInit[attention][{$vo.key}]" rel="haveInit[attention]" checked type="checkbox" value="{$vo.uid}" /></div>
	                        	<div class="L" style="width:140px;"><a class="preview" rel="{$vo.uid}" href="{:U('space/View/index',array('uid'=>$vo['uid']))}" target="_blank">{$vo.fullname}</a></div>
	                            <div class="L" style="width:110px;">
									<input type="hidden" name="haveInit[fid][{$vo.key}]" value="{$vo.uid}">
									<select class="mt5" name="haveInit[gid][{$vo.key}]" id="gid" class="mr5">
			                        	<volist id="svo" name="grouplist">
			                        		<php>$selected = ($gid==$key)?'selected':''</php>
			                        		<option value="{$key}" {$selected}>{$svo}</option>
			                        	</volist>
			                        </select>
	                   		    </div>
                        		<div class="L" style="width:80px;" id="c_status_{$vo.key}">
									{:L('add_waiting')}</div>
								<div class="L mt5"  style="width:20px;">
									<a class="del" href="javascript:void(0)" onclick="remove({$vo.key})"></a>
								</div>
	
							<div class="C"></div>
	                      </div>

    				</volist>
                    </div>
                      <div class="clewbox L">
                	<div class="clewbox_bg">{:L('tip')}: </div>
                    <div class="clewbox_bg_b">{:L('tip_transact_1')}</div>
                </div>
                <div class="C"></div>
                    </li>
					<div class="ml10 mt10"> <input type="button" class="btn_sea" value="{:L('add')}" onclick="doaddhavaInit()" /></div>
				    </ul>
					
                    
					</form>
	<php>if($findlist['unhaveInit']){</php>
                    <h2 class="fB lh30 btmline">{:L('tip_transact_2')}: </h2>


  <ul style="margin-top: 10px;" id="div_unInit">
  	<form action="__URL__&act=doadd" method="post" id="form_unInit" autocomplete="off" />
	<input type="hidden" name="invitemessage" id="invitemessage" />
	<input type="hidden" name="type" value="unInit" />
                    <li class="ml10">
                    <div class="copylist L" style="width:450px;">
                    	<div class="tit_t">
                   	    	<div class="L alC" style="width:60px;">{:L('select_all')} <input name="" type="checkbox" value="" checked="true" onclick="tChecked(this,'unInit[attention]')" /></div>
                        <div class="L" style="width:140px;">{:L('follow_col')}</div>
                            <div class="L" style="width:110px;">{:L('col_group')}</div>				                     		
		                    <div class="L" style="width:80px;">{:L('status')}</div>
							<div class="L" style="width:30px;">{:L('remove')}</div>
                    		<div class="C"></div>
						</div>
                    <volist id="vo" name="findlist['unhaveInit']" key="k">                    	
                      <div class="tit_C" style="padding:0" id="c_list_{$vo.key}">
                   	    <div class="L alC" style="width:60px;"><input style="margin-left:28px; margin-top:8px;*margin-top:5px;" name="unInit[attention][{$vo.key}]" rel="unInit[attention]" checked type="checkbox" value="1" /></div>
                        	<div class="L" style="width:140px;">{$vo.uname}</div>
                            <div class="L" style="width:110px;">
								<input type="hidden" name="unInit[uname][{$vo.key}]" value="{$vo.uname}">
								<select class="mt5" name="unInit[gid][{$vo.key}]" id="gid" class="mr5">
		                        	<volist id="svo" name="grouplist">
		                        		<php>$selected = ($gid==$key)?'selected':''</php>
		                        		<option value="{$key}" {$selected}>{$svo}</option>
		                        	</volist>
		                        </select>
                   		    </div>
						<div class="L" style="width:80px;" id="c_status_{$vo.key}">{:L('add_waiting')}</div>
						<div class="L mt5" style="width:20px;">
							<a class="del" href="javascript:void(0)" onclick="remove({$vo.key})"></a>
						</div>
						<div class="C"></div>
                      </div>
    				</volist>
                    </div>
                      <div class="clewbox L">
                	<div class="clewbox_bg">{:L('tip')}: </div>
                    <div class="clewbox_bg_b">{:L('tip_transact_3')}</div>
                </div>
                <div class="C"></div>					
					
                    </li>
					</form>
					<div class="ml10 mt10"> <input type="submit" class="btn_sea mr5" onclick="doinvite()" value="{:L('add')}" /><input type="button" class="btn_sea" value="{:L('return')}" onclick="javascript:history.back(-1)" name=""/> </div>
                </ul> 

	<php>}</php>
                        
            </div>   
			
  </div>
  </div>
	</div>
    </div>
  <div class="C"></div>
  </div>
<script>
	//移除
	function remove(id){
		if($("#c_list_"+id).attr('rel')=='del'){
			$("#c_list_"+id).removeAttr('rel');
			$("#c_list_"+id+" input").removeAttr('disabled');
			$("#c_list_"+id+" select").removeAttr('disabled');
			$("#c_status_"+id).html('{:L("add_waiting")}');
		}else{
			$("#c_list_"+id).attr('rel','del');
			$("#c_list_"+id+" input").attr('disabled',true);
			$("#c_list_"+id+" select").attr('disabled',true);
			$("#c_status_"+id).html('<font color="red">{:L("removed")}</font>');
		}
	}


	//添加到同事列表
	function doaddhavaInit(){
		var options={
			//beforeSubmit:  showRequest, 
			success:       function(txt){
				var result = eval('('+txt+')');
				if(result.status){
					$('#div_havaInit').html('<li>{:L("tip_transact_4_1")}: '+result.info.list +' '+ result.info.number + '{:L("tip_transact_4_2")}</li>');
				}else{
					alert(result.info);
				}
			}
		};
		$("#form_havaInit").ajaxSubmit(options);
	}
	
	//邀请未激活的同事加入调窗
	function doinvite(){
		var html = '<div style="width:350px"><ul style="margin:5px">'
			     + '<li>{:L("inviting_msg")}:<textarea style="width:100%" id="inputMessage">{:L("tip_transact_5")}</textarea></li>'
			     + '<li>{:L("tip_transact_6")}</li>'
			     + '</ul></div>'
			     + '<div style="display: block;" id="tb_content_list" class="tb_button_list">'
			     + '<p><input type="button" value="{:L(ok)}" onclick="doaddunInit()" id="tb_button_ok" class="mr10"/><input type="button" value="{:L("cancel")}" id="tb_button_no" onclick="$.tbox.close()" name="" class="mr10"/>'
			     + '</p></div>';
		$.tbox.popBox(html,'{:L("invite_col")}');
	}
	
	//邀请未激活的同事加入操作
	function doaddunInit(){
		$.tbox.close();
		$('#invitemessage').val($('#inputMessage').val());
		var options={
			success:       function(txt){
				var result = eval('('+txt+')');
				if(result.status){
					$('#div_unInit').html('<li>{:L("tip_transact_7_1")} '+result.info.list +' '+ result.info.number + '{:L("tip_transact_7_2")}</li>');
				}else{
					alert(result.info);
				}
			}
		};
		$("#form_unInit").ajaxSubmit(options);
	}
	
	
</script>  
<include file="__THEME__/footer" />  	
		